//
//  TTViewController.m
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTViewController.h"

@implementation TTViewController


#pragma mark - Accessors

@synthesize viewAppeared = _viewAppeared;


@synthesize appearedTimes = _appearedTimes;


@synthesize observeKeyboard = _observeKeyboard;

- (void)setObserveKeyboard:(BOOL)observeKeyboard {
    if (!TTIsBoolEqualToBool(_observeKeyboard, observeKeyboard)) {
        _observeKeyboard = observeKeyboard;
        
        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
        if (_observeKeyboard) {
            [nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
            [nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
            [nc addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
            [nc addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
        } else {
            [nc removeObserver:self name:UIKeyboardWillShowNotification object:nil];
            [nc removeObserver:self name:UIKeyboardWillHideNotification object:nil];
            [nc removeObserver:self name:UIKeyboardDidShowNotification object:nil];
            [nc removeObserver:self name:UIKeyboardDidHideNotification object:nil];
        }
    }
}


@synthesize contentLoading = _contentLoading;

- (void)setContentLoading:(BOOL)contentLoading {
    _contentLoading = contentLoading;
    if (_contentLoading) {
        [self setLoadingState];
    } else {
        [self setNormalState];
    }
}



#pragma mark - Memory

- (id)init {
    self = [super init];
    if (self) {
        _viewAppeared = NO;
        _appearedTimes = 0;
        _observeKeyboard = NO;
        _contentLoading = NO;
    }
    return self;
}

- (void)dealloc {
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [nc removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    [nc removeObserver:self name:UIKeyboardDidShowNotification object:nil];
    [nc removeObserver:self name:UIKeyboardDidHideNotification object:nil];
    
    _viewAppeared = NO;
    _appearedTimes = 0;
    _observeKeyboard = NO;
    _contentLoading = NO;
    
    [super dealloc];
}



#pragma mark - UIViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    _viewAppeared = YES;
    _appearedTimes++;
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    _viewAppeared = NO;
}



#pragma mark - Keyboard

- (void)keyboardWillShow:(NSNotification *)notification {
}

- (void)keyboardWillHide:(NSNotification *)notification {
}

- (void)keyboardDidShow:(NSNotification *)notification {
}

- (void)keyboardDidHide:(NSNotification *)notification {
}


#pragma mark - Content loading

- (void)setLoadingState {
}

- (void)setNormalState {
}

@end
